<%--
  Created by IntelliJ IDEA.
  User: xianfei
  Date: 15-8-15
  Time: 上午10:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
    <title>销售管理</title>
    <style>
        .area {
            width: 150px;
        }
    </style>
    <script>
        $(function () {
            change();
        })
        function reduce(type) {
            var guid = $("#area").val();
            $.ajax({
                url: '/sell/operate/' + guid + "/" + type,
                type: 'get',
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    location.reload();
                }
            })
        }

        function change() {
            var guid = $("#area").val();
            $.ajax({
                url: '/sell/data_content/' + guid,
                type: 'get',
                dataType: 'json',
                success: function (data) {
                    $("#goldNum").html(data.gold);
                    $("#busyNum").html(data.busy);
                    $("#slackNum").html(data.slack);
                    $("#commonNum").html(data.common);
                }
            })

        }

    </script>
</head>
<body>
<div>
    <select id="area" onchange="change()" class="form-control area">
        <c:forEach items="${sellManagerDTOs}" var="sell">
            <option value="${sell.guid}">${sell.areaAsString}</option>
        </c:forEach>
    </select>
</div>
<table class="table table-striped">
    <thead>
    <th>周次</th>
    <th>剩余份数</th>
    <th>操作</th>
    </thead>
    <tbody>
    <tr>
        <td>黄金周</td>
        <td><label id="goldNum"></label></td>
        <td><input type="button" class="btn btn-info" onclick="reduce('gold')" value="减"></td>
    </tr>
    <tr>
        <td>旺季周</td>
        <td><label id="busyNum"></label></td>
        <td><input type="button" class="btn btn-info" onclick="reduce('busy')" value="减"></td>
    </tr>
    <tr>
        <td>平季周</td>
        <td><label id="slackNum"></label></td>
        <td><input type="button" class="btn btn-info" onclick="reduce('slack')" value="减"></td>
    </tr>
    <tr>
        <td>淡季周</td>
        <td><label id="commonNum"></label></td>
        <td><input type="button" class="btn btn-info" onclick="reduce('common')" value="减"></td>
    </tr>
    </tbody>
</table>
</body>
</html>